<include file="Public/header"/>
<style>
    .edge,.pendant a{margin-left:0px;}
</style>
<div class="wrapperBox">
	<div class="centrecon">
		<div class="con-inner">
	 	  <h1 class="title">{$info['article_title']}</h1>
	 	  <div class="article-container">
	 	  	  {$info['article_content']}
	 	  </div>
	 	   <notempty name="list">
	 	   <div class="mainbox">
				<volist name="list" id="vo">
		 	 	<div class="feed-item">
		 	 		<h3><notempty name="vo['Member']['nickname']">{$vo['Member']['nickname']}<else/>{$vo['Member']['member_name']}</notempty></h3>
		 	 		<div class="txt">
		 	 			{$vo['content']}
		 	 		</div>
		 	 		<div class="bo">
		 	 			<a class="share" href="javascript:">·分享</a>
		 	 			<eq name="vo['follow']" value="0">
		 	 			<a class="edge concern" href="javascript:follow({$vo['id']},0)">·关注</a>
		 	 			<else/>
		 	 			<a class="edge concern" href="javascript:follow({$vo['id']},0)">·取消关注</a>
		 	 			</eq>
		 	 			<a class="edge invite" href="javascript:">·邀请回答</a>
                        <a id="dingyue_{$vo['id']}" class="edge unbind" href="javascript:dingyue({$vo['id']},{$info['article_id']})">·订阅</a>
		 	 			<a class="edge zc-comment" href="javascript:">·支持评论</a>
		 	 			<a class="edge zc-comment" href="javascript:">·反驳评论{$vo['agree']}</a>
		 	 			<a id="follow_{$vo['id']}_1" <eq name="vo['agree']" value="0">class="edge unbind" href="javascript:follow({$vo['id']},1)"<else/>class="edge" href="javascript:" style="color: rgb(195, 188, 188); cursor: text;"</eq>>·赞成(<i>{$vo['agree_num']}</i>)</a>
                        <a id="follow_{$vo['id']}_-1" <eq name="vo['against']" value="0">class="edge unbind" href="javascript:follow({$vo['id']},-1)"<else/>class="edge" href="javascript:" style="color: rgb(195, 188, 188); cursor: text;"</eq>>·反对(<i>{$vo['against_num']}</i>)</a>

                        <neq name="info['mode']" value="0">
                        <a id="useful_{$vo['id']}_1" <eq name="vo['useful']" value="0">class="edge unbind" href="javascript:useful({$vo['id']},1)"<else/>class="edge" href="javascript:" style="color: rgb(195, 188, 188); cursor: text;"</eq>>·值(<i>{$vo['useful_num']}</i>)</a>
                        <a id="useful_{$vo['id']}_-1" <eq name="vo['useless']" value="0">class="edge unbind" href="javascript:useful({$vo['id']},-1)"<else/>class="edge" href="javascript:" style="color: rgb(195, 188, 188); cursor: text;"</eq>>·不值(<i>{$vo['useless_num']}</i>)</a>
                        </neq>
                        </a><a class="unfold" href="javascript:">·收起内容</a>
		 	 			
		 	 			<if condition="$session_id eq $vo['member_id']">
		 	 			<a class="barbecue" dialog_id="edit" nc_type="dialog" dialog_title="重新编辑" dialog_width="500" uri="{:U('rewrite',array('id'=>$vo['id']))}" href="javascript:void(0);">编辑</a>
		 	 			<else />
		 	 			</if>
                        <a class="barbecue" dialog_id="dashang" nc_type="dialog" dialog_title="打赏" dialog_width="500" uri="{:U('dashang',array('id'=>$vo['id']))}" href="javascript:void(0);">打赏</a>
                        <a class="barbecue" dialog_id="report" nc_type="dialog" dialog_title="举报" dialog_width="500" uri="{:U('report',array('id'=>$vo['id']))}" href="javascript:void(0);">举报</a>
		 	 			
		 	 			<div class="share-box jiathis_style_32x32">
						      <div class="jiathis_style">
								  <a class="jiathis_button_qzone"></a>
								  <a class="jiathis_button_tsina"></a>
								  <a class="jiathis_button_tqq"></a>
								  <a class="jiathis_button_weixin"></a>
							  </div>
						</div>
		 	 		</div>

			<!-- 邀请回答 -->
				<div class="Invited-box">
					<div class="Invited-member-box">
						<ul class="member_user_res">
							<volist name="grop" id="v">
							<li class="list_num">
								<a class="member-pic" href="">
								<if condition="empty($v['avatar'])">
								<img src="__UPLOADS__/{$v['avatar']}" width="50" height="50" alt="">
								<else/>
								<img src="__IMG__/defaultpic.png" width="50" height="50" alt="">
								</if>
								</a>
								<button class="Invited-but" onclick="invitation({$info['article_id']},{$v['member_id']})">邀请辩论</button>
								 <div class="member-info">
								 	  <a class="member-name" href="">{$v['member_name']}</a> <span> {$v['introduce']}</span>
								 	  <div class="profession">{$v['profession']}</div>
								 </div>
								 <div class="clear"></div>
							</li>
							</volist>
						</ul>
							<div class="pro_page">  
									<a onclick="more_num({$info['article_id']})">加载更多</a>
						    </div>
					</div>
					
				</div>

                <script type="text/javascript">
                    function more_num(aid){
                        var limit_num = $(".list_num").length;
                        var limit = limit_num/2;
                        var URL = "{:U('Index/more_num')}";
                        var data = {'num':limit,'aid':aid};
                        $.get(URL,data,function(res){
                            if(res)
                            {
                                $(".member_user_res").append(res);
                            }else{
                                $(".more").hide();
                            }
                        });
                    }
                </script>

             <!-- 评论区 -->
		 	 		<div class="comment">
		 	 			<div class="endorse"><h1>赞成</h1>
		 	 				<notempty name="vo['agree_list']">
							<volist name="vo['agree_list']" id="v">
		 	 				<div class="member-box">
								<div class="com-name">
								<a class="memberID" href="">{$v['Member']['member_id']|get_member_nickname}:</a>
								
								<if condition="$v['pid'] neq $v['c_pid']">
								<span class="rep"> <if condition="get_reply_position($v['id'])">同意<else/>反驳</if> </span><a href="">{$v['reply_member_id']|get_member_nickname}</a>
								</if>
								
								<div style="font-size:12px; color:#A4A4A4;">
								<if condition="$v['pid'] neq $v['c_pid'] ">
								{$v['pid']|get_member_content}
								</if>
								</div>
								
								</div>
								<div class="com-container">{$v['content']}</div>

								<!-- 点赞评论部分 -->
								<div class="pendant">
									<span class="switch">
						 	 			<if condition="$session_id eq $vo['member_id']">
						 	 			<a class="barbecue" dialog_id="edit" nc_type="dialog" dialog_title="重新编辑" dialog_width="500" uri="{:U('rewrite',array('id'=>$v['id']))}" href="javascript:void(0);">编辑</a>
						 	 			<else />
						 	 			</if>									
									<a class="suppor-reply" aid="{$info[article_id]}" bid="{$v['id']}" cid="childcomment" did="1" eid="{$vo['id']}" href="javascript:">·支持回复</a>
									<a class="suppor-fanbo" aid="{$info[article_id]}" bid="{$v['id']}" cid="childcomment" did="-1" eid="{$vo['id']}" href="javascript:">·反驳</a></span>
									<a id="follow_{$v['id']}_1" <eq name="v['agree']" value="0">class="edge unbind" href="javascript:follow({$v['id']},1)"<else/>class="edge" href="javascript:" style="color: rgb(195, 188, 188); cursor: text;"</eq>>·赞成(<i>{$v['agree_num']}</i>)</a>
		 	 						<a id="follow_{$v['id']}_-1" <eq name="v['against']" value="0">class="edge unbind" href="javascript:follow({$v['id']},-1)"<else/>class="edge" href="javascript:" style="color: rgb(195, 188, 188); cursor: text;"</eq>>·反对(<i>{$v['against_num']}</i>)</a>
                                    <a class="barbecue" dialog_id="report" nc_type="dialog" dialog_title="举报" dialog_width="500" uri="{:U('report',array('id'=>$v['id']))}" href="javascript:void(0);">举报</a>
								</div>

								<div class="txtbox"></div>
							</div>
							</volist>
							<notempty name="vo['agree_next']">
							<div class="more" id="getMoreAgree_{$vo['id']}_before"><a href="JavaScript:void(0);" id="getMoreAgree_{$vo['id']}" count="{:count($vo['agree_list'])}" onclick="getMoreComment({$vo['id']},1)">查看更多评论</a></div>
							</notempty>
							<else/>
							<div class="more"><a href="">暂无评论</a></div>
							</notempty>
						<div id="support-comment" name="support-comment" class="txtbox bcolor">
							<div class="t" contenteditable="true" id="agree{$vo['id']}"><p style="color:#A3A0A0;">写下我的支持回复</p></div>
							 <div class="r">
							 	<a class="comment-but" href="JavaScript:void(0);" onclick="submitComment({$info[article_id]},{$vo['id']},'agree{$vo['id']}',1,{$vo['id']})">评论</a><a href="" class="comment-cancel">取消</a>
							 </div>
						 </div>
		 	 			</div>
<!-- ====================================================================反对========================= -->
		 	 			<div class="oppose"><h1>反对</h1>
		 	 				<notempty name="vo['against_list']">
			 	 			<volist name="vo['against_list']" id="v">
		 	 				<div class="member-box">
								<div class="com-name">
								<a class="memberID" href="">{$v['Member']['member_id']|get_member_nickname}:</a>
								<if condition="$v['pid'] neq $v['c_pid']">
								<span class="rep"> <if condition="get_reply_position($v['id'])">同意<else/>反驳</if> </span><a href="">{$v['reply_member_id']|get_member_nickname}</a>
								</if>
								
								<div style="font-size:12px; color:#A4A4A4;">
								<if condition="$v['pid'] neq $v['c_pid'] ">
								{$v['pid']|get_member_content}
								</if>
								</div>
								
								</div>
								<div class="com-container">{$v['content']}</div>

								<!-- 点赞评论部分 -->
								<div class="pendant">
									<span class="switch">
						 	 			<if condition="$session_id eq $v['Member']['member_id']">
						 	 			<a class="barbecue" dialog_id="edit" nc_type="dialog" dialog_title="重新编辑" dialog_width="500" uri="{:U('rewrite',array('id'=>$v['id']))}" href="javascript:void(0);">编辑</a>
						 	 			<else />
						 	 			</if>																			
									<a class="suppor-reply" aid="{$info[article_id]}" bid="{$v['id']}" cid="childcomment" did="-1" eid="{$vo['id']}" href="javascript:">·支持回复</a>
									<a class="suppor-fanbo" aid="{$info[article_id]}" bid="{$v['id']}" cid="childcomment" did="1" eid="{$vo['id']}" href="javascript:">·反驳</a></span>
									<a id="follow_{$v['id']}_1" <eq name="v['agree']" value="0">class="edge unbind" href="javascript:follow({$v['id']},1)"<else/>class="edge" href="javascript:" style="color: rgb(195, 188, 188); cursor: text;"</eq>>·赞成(<i>{$v['agree_num']}</i>)</a>
		 	 						<a id="follow_{$v['id']}_-1" <eq name="v['against']" value="0">class="edge unbind" href="javascript:follow({$v['id']},-1)"<else/>class="edge" href="javascript:" style="color: rgb(195, 188, 188); cursor: text;"</eq>>·反对(<i>{$v['against_num']}</i>)</a>
                                    <a class="barbecue" dialog_id="report" nc_type="dialog" dialog_title="举报" dialog_width="500" uri="{:U('report',array('id'=>$v['id']))}" href="javascript:void(0);">举报</a>
								</div>

								<div class="txtbox"></div>
							</div>
							</volist>
							<notempty name="vo['against_next']">
                            <div class="more" id="getMoreAgainst_{$vo['id']}_before"><a href="JavaScript:void(0);" id="getMoreAgainst_{$vo['id']}" count="{:count($vo['against_list'])}" onclick="getMoreComment({$vo['id']},-1)">查看更多评论</a></div>
                            </notempty>
                            <else/>
							<div class="more"><a href="">暂无评论</a></div>
							</notempty>
							<div  id="oppose-comment" class="txtbox bcolor">
								<div class="t" contenteditable="true" id="against{$vo['id']}"><p style="color:#A3A0A0;">写下我的反驳</p></div>
								 <div class="r">
								 	<a class="comment-but" href="JavaScript:void(0);" onclick="submitComment({$info[article_id]},{$vo['id']},'against{$vo['id']}',-1,{$vo['id']})">评论</a><a href="" class="comment-cancel">取消</a>
								 </div>
							 </div>
		 	 			</div>
					 <!-- 清除浮动 -->
 	 		    	<div class="clear"></div>
		 	 		</div>
		 	 		<!-- 评论区 end-->
		 	 	</div>
		 	 	</volist>
				<div class="pro_page">{$page}</div>
              </div>
              </notempty>

              <div class="reply">
				<div class="rele">发表</div>
				<div contenteditable="true"> 
					 <textarea name="comment_content" id="comment_content" style="width: 790px; height: 200px;"></textarea>
				</div>
				<div><a class="but-fab" href="javascript:void(0);" onclick="submitComment({$info[article_id]},0,'comment_content',0)">发 表</a>
					<!-- 清除浮动 -->
	 	            <div class="clear"></div>
				</div>
              </div>

	 	</div>
		{:W('Question/rightPlate',array($info[article_id]))}
	 	<!-- 清除浮动 -->
	 	<div class="clear"></div>
	</div>

<div class="footer">
	<div class="wrapperBox">
      <p> Copyright © 2004-2015 icp号:123456789  </p>    
    </div>   
</div>

</div>
</body>
<script type="text/javascript">
	$(function(){
		CreateNode();
		$('.unbind').click(function(){
			 $(this).unbind("click");
		});
	});

    //邀请
	function invitation(aid,mid){
		var URL = "{:U('Index/invitation')}";
		var data = {'aid':aid,'mid':mid};
		$.post(URL, data, function() {
			alert('邀请成功');
			/*optional stuff to do after success */
		});
	}

    //赞同与反对
	function follow(id,position){
		var URL = "{:U('Index/follow')}";
		var data = {'id':id,'position':position};
		$.post(URL, data, function(data){
			$("#follow_"+id+"_"+position).attr("href","JavaScript:void(0)");
			$("#follow_"+id+"_"+position).css({
			 	'color':'#C3BCBC',
			 	'cursor':'text'
			 });

			var zc=$("#follow_"+id+"_"+"1");
			var fd=$("#follow_"+id+"_"+"-1");
			zc.attr("href","JavaScript:void(0)");
			zc.css({
			 	'color':'#C3BCBC',
			 	'cursor':'text'
			 });
			fd.attr("href","JavaScript:void(0)");
			fd.css({
			 	'color':'#C3BCBC',
			 	'cursor':'text'
			 });
			 CountAgree($("#follow_"+id+"_"+position));
		});
	}

    //值与不值
    function useful(id,position){
        var URL = "{:U('Index/useful')}";
        var data = {'id':id,'position':position};
        $.post(URL, data, function(data){
            $("#useful_"+id+"_"+position).attr("href","JavaScript:void(0)");
            $("#useful_"+id+"_"+position).css({
                'color':'#C3BCBC',
                'cursor':'text'
            });

            var zc=$("#useful_"+id+"_"+"1");
            var fd=$("#useful_"+id+"_"+"-1");
            zc.attr("href","JavaScript:void(0)");
            zc.css({
                'color':'#C3BCBC',
                'cursor':'text'
            });
            fd.attr("href","JavaScript:void(0)");
            fd.css({
                'color':'#C3BCBC',
                'cursor':'text'
            });
            CountAgree($("#useful_"+id+"_"+position));
        });
    }

    //提交评论
	function submitComment(id,pid,tid,position,c_pid){
		var mid = "{$mid}";
		if (mid == "") {
			alert('请登录后再发表评论');
			return false;
		};
		var URL = "{:U('Index/comment')}";
		if (tid == 'comment_content') {
			var content = $.trim($("#"+tid).val());
		}else {
			var content = $.trim($("#"+tid).text());
		}
		if (content == '') {
			alert('请填写您的观点.');
			return false;
		};
		var data = {'id':id,'pid':pid,'content':content,'position':position,'c_pid':c_pid};
		$.post(URL, data, function(data) {
			alert(data.msg);
			if (data.status == true) {
				if (tid == 'comment_content') {
					$("#"+tid).val('');
				}else {
					$("#"+tid).text('');
				}
				location.reload();
			};
		},"json");
	}

    //显示更多评论
	function getMoreComment(id,position){
		var aid = "{$info['article_id']}";
		if (position == 1) {
			var start = $("#getMoreAgree_"+id).attr('count');
		}else{
			var start = $("#getMoreAgainst_"+id).attr('count');
		}
		var URL = "{:U('Index/getMoreComment')}";
		var data = {'id':id,'position':position,'start':start,'aid':aid};
		$.post(URL, data, function(list) {
			if (list.status == true) {
				if (position == 1) {
					$("#getMoreAgree_"+id+"_before").before(list.list);
					if (list.nextstatus == 0) {
						$("#getMoreAgree_"+id).remove();
					}else{
						$("#getMoreAgree_"+id).attr('count',list.count);
					}
				}else{
					$("#getMoreAgainst_"+id).attr('count',list.count);
					$("#getMoreAgainst_"+id+"_before").before(list.list);
					if (list.nextstatus == 0) {
						$("#getMoreAgainst_"+id).remove();
					}else{
						$("#getMoreAgainst_"+id).attr('count',list.count);
					}
				}
			};
			CreateNode();
		},"json");
	}

    //创建评论框
    function CreateNode(){
        var but=$('.suppor-reply');
        var fanbobut=$('.suppor-fanbo');
        fanbobut.click(function(){
              var txtbox=$(this).parent().parent().next('.txtbox'); //获取textbox
              var aid = $(this).attr('aid');
              var bid = $(this).attr('bid');
              var cid = $(this).attr('cid');
              var did = $(this).attr('did');
              var eid = $(this).attr('eid');
              var fanbo=$('<div class="t" contenteditable="true" id="childcomment"></div> <div class="r"> <a class="comment-but" onclick="submitComment('+aid+','+bid+',\'childcomment\','+did+','+eid+')"  href="javascript:">反驳</a><a onclick="cancel(this)" href="javascript:" class="comment-cancel">取消</a></div>');
              txtbox.html(fanbo);
        });
        but.click(function(){
              var txtbox=$(this).parent().parent().next('.txtbox'); //获取textbox
              var aid = $(this).attr('aid');
              var bid = $(this).attr('bid');
              var did = $(this).attr('did');
              var eid = $(this).attr('eid');
              var node=$('<div class="t" contenteditable="true" id="childcomment"></div> <div class="r"> <a class="comment-but" onclick="submitComment('+aid+','+bid+',\'childcomment\','+did+','+eid+')" href="javascript:">评论</a><a onclick="cancel(this)" href="javascript:" class="comment-cancel">取消</a></div>');
              txtbox.html(node);
        });
    }

    //订阅
    function dingyue(id,ac_id){
        var URL = "{:U('Index/dingyue')}";
        var data = {'id':id,'ac_id':ac_id};
        $.post(URL, data, function(data){
            alert(data.msg);//成功提示
            if (data.status == true) {
                $("#dingyue_"+id).attr("href","JavaScript:void(0)");
                $("#dingyue_"+id).css({
                    'color':'#C3BCBC',
                    'cursor':'text'
                });
                location.reload();  //重载
            };
        },"json");
    }


</script>

<script type="text/javascript" src="__STATIC__/common.js"></script>  
<script language="javascript" src="__STATIC__/dialog/dialog.js"  id="dialog_js" charset="utf-8"> </script> 
<script type="text/javascript" src="__STATIC__/jquery-ui/jquery.ui.js"></script> 
<script type="text/javascript" src="__STATIC__/jquery-ui/i18n/zh-CN.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="__STATIC__/jquery-ui/themes/ui-lightness/jquery.ui.css"  />
<link href="__STATIC__/dialog/custom.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
$('a[nc_type="dialog"]').click(function(){
	var id = $(this).attr('dialog_id');
	var title = $(this).attr('dialog_title') ? $(this).attr('dialog_title') : '';
	var url = $(this).attr('uri');
	var width = $(this).attr('dialog_width');
	CUR_DIALOG = ajax_form(id, title, url, width,0);
	return false;
});
</script>
<!-- 分享js -->
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
</html>